FROM debian:bookworm-slim

# 配置git
RUN mkdir -p /root/.ssh && \
    chmod 700 /root/.ssh

COPY config/git/.ssh/id_rsa /root/.ssh/
COPY config/git/.ssh/id_rsa.pub /root/.ssh/

# COPY ./git/.gitconfig /root/

RUN apt-get update && \
    apt-get install -y git default-mysql-client && \
    git --version && \
    rm -rf /var/lib/apt/lists/* && \
    chmod 600 /root/.ssh/id_rsa

# 拉取gitee的公钥
RUN ssh-keyscan -t rsa,ecdsa,ed25519 gitee.com >> ~/.ssh/known_hosts 2>/dev/null

# 确保 /usr/bin 在 PATH 中
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# 安装autodb
RUN mkdir "/usr/sjy"
COPY ./autodb/autodb /usr/sjy/
COPY config/config.yaml /usr/sjy/
COPY ./shell/start_up.sh /usr/sjy/

EXPOSE 11000

CMD [ "/usr/sjy/autodb", "-c", "/usr/sjy/config.yaml" ]
